#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	freopen("sub.in", "r", stdin);
	freopen("sub.out", "w", stdout);
	int t;
	cin >> t;
	while(t--){
		int a, b;
		scanf("%d%d", &a, &b);
        b=-b;
		if(1ll*a*b<=0){
			puts("0");
		}else{
			printf("%d\n", min({abs(a), abs(b), abs(a-b)}));
		}
	}
	return 0;
}
